package com.spring.core.scan;

import com.spring.core.context.AbstractApplicationContext;

import java.io.IOException;
import java.io.InputStream;

/**
 * spring配置文件扫描
 *
 * @author Zee
 * @version 1.0
 * @date 2021/10/13
 */
public class SpringConfigPropertiesScanner implements Scanner {


    @Override
    public void doScanner(String scanPackage, AbstractApplicationContext context) {
        System.out.println("扫描Application配置文件...");
        InputStream is = this.getClass().getResourceAsStream(scanPackage);
        try {
            context.getProperties().load(is);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (null != is) {
                try {
                    is.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

        }
    }
}
